﻿
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;
using System.Text.RegularExpressions;

namespace Web.Pages.QuShui.DiXiaS.ChaXunGL
{
    public partial class QuanNianQKCX : BasePage
    {
        #region 属性
        private int _WType;

        public int WType
        {
            get { return ViewState["_WType"] == null ? 0 : Convert.ToInt32(ViewState["_WType"]); }
            set { ViewState["_WType"] = value; }
        }


        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtYongHuXX
        {
            get
            {
                return ViewState["dtYongHuXX"] as DataTable;
            }
            set
            {
                ViewState["dtYongHuXX"] = value;
            }
        }


        private DataTable dtGridTab2_1
        {
            get
            {
                return ViewState["dtGridTab2_1"] as DataTable;
            }
            set
            {
                ViewState["dtGridTab2_1"] = value;
            }
        }

        private DataTable dtGridTab2_2
        {
            get
            {
                return ViewState["dtGridTab2_2"] as DataTable;
            }
            set
            {
                ViewState["dtGridTab2_2"] = value;
            }
        }
        /// <summary>
        /// //////////////////////////////////////////////////////////
        /// </summary>
        private DataTable dtGridTab3
        {
            get
            {
                return ViewState["dtGridTab3"] as DataTable;
            }
            set
            {
                ViewState["dtGridTab3"] = value;
            }
        }

        private DataTable dtGridTab4
        {
            get
            {
                return ViewState["dtGridTab4"] as DataTable;
            }
            set
            {
                ViewState["dtGridTab4"] = value;
            }
        }



















        private DataTable dtSource5_1
        {
            get
            {
                return ViewState["dtSource5_1"] as DataTable;
            }
            set
            {
                ViewState["dtSource5_1"] = value;
            }
        } 


        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        /// <summary>
        /// 行政区
        /// </summary>
        QS_JX_XINGZHENGQBLL XZQ = new QS_JX_XINGZHENGQBLL();
        /// <summary>
        /// 行业分类
        /// </summary>
        QS_JX_HANGYEFLXXBLL HYFL = new QS_JX_HANGYEFLXXBLL();
        /// <summary>
        /// 取水用途
        /// </summary>
        QS_JX_QUSHUIXXBLL QSYT = new QS_JX_QUSHUIXXBLL();
        /// <summary>
        /// 管理部门
        /// </summary>
        QS_JX_BUMENXXBLL GLBM = new QS_JX_BUMENXXBLL();
        /// <summary>
        /// 流域信息
        /// </summary>
        QS_JX_LIUYUXXBLL LYXX = new QS_JX_LIUYUXXBLL();
        /// <summary>
        /// 水利分片
        /// </summary>
        QS_JX_SHUILIFPXXBLL SLFP = new QS_JX_SHUILIFPXXBLL();
        /// <summary>
        /// 水资源分区
        /// </summary>
        QS_JX_SHUIZIYFQBLL SZYFQ = new QS_JX_SHUIZIYFQBLL();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            this.gvYongHuXX.DataSource = this.dtYongHuXX;
            this.gvYongHuXX.DataBind();
            gvGrid1Tab5.DataSource = this.dtSource5_1;
            gvGrid1Tab5.DataBind();
        }




        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            if (cmbYear.Value.ToString() != "")
            {
                LoadGridData();
                if (this.dtYongHuXX == null || this.dtYongHuXX.Rows.Count < 1)
                {
                    txtYongHuH2.Text = "";
                    txtYongHuM2.Text = "";
                    txtHuanNeiHW.Text = "";
                    txYouBian.Text = "";
                    txtDiZhi.Text = "";
                    txtXingZhengQ.Text = "";
                    txtLianXiBM.Text = "";
                    txtLianXiR.Text = "";
                    txtLianXiDH.Text = "";
                    txtLiuYu.Text = "";
                    txtYeWuY.Text = "";
                    txtGuanLiBM.Text = "";
                    txtShuiZiYFQ.Text = "";
                    txtShouFeiFS.Text = "";
                    txtShuiJia2.Text = "";
                    txtQuShuiYT.Text = "";
                    txtShuiLiFP.Text = "";
                    txtKaiHuHM2.Text = "";
                    txtHangYeFL.Text = "";
                    memoBeiZhu.Text = "";
                    txtYinHangZH2.Text = "";
                    txtJingShu.Text = "";
                    txtKaiHuYH.Text = "";
                    txtBiaoShu.Text = "";
                    zjl.Text = "共0条";
                }
            }
        }


       


        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            int wtype = BusinessTool.WType;
            if (wtype == 1)
            {
                cmbHuiZonglx.Items.Add("按行政区", 0);
                cmbHuiZonglx.Items.Add("按取水用途", 1);
                cmbHuiZonglx.Items.Add("按行业类别", 2);
                rabGuanLiBM.ClientVisible = false;
                cbmGuanLiBM.ClientVisible = false;
                rabShouFeiFS.ClientVisible = false;
                cmbShouFeiFS.ClientVisible = false;
            }
            else if (wtype == 2)
            {
                cmbHuiZonglx.Items.Add("按行政区", 0);
                cmbHuiZonglx.Items.Add("按取水用途", 1);
                cmbHuiZonglx.Items.Add("按行业类别", 2);
                cmbHuiZonglx.Items.Add("按主管部门", 3);
                cmbHuiZonglx.Items.Add("按环线内外", 4);
                cmbHuiZonglx.Items.Add("按水价", 5);
            }
            cmbHuiZonglx.SelectedIndex = 0;
            gvYongHuXX.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //水量年月
            string water_y_m = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();
            for (int i = DateTime.Now.Year - 10; i <= DateTime.Now.Year; i++)
            {
                cmbYear.Items.Add(i.ToString() , i.ToString());
            }
            cmbMonth.Items.Add("全部", 0);

            for (int i = 1; i <= 12; i++)
            {
                cmbMonth.Items.Add(i.ToString(), i.ToString());
            }
            //业务员
            //LoadYWY();
            cmbYear.Value = Convert.ToInt32(water_y_m) / 100;
            cmbMonth.Value = Convert.ToInt32(water_y_m) % 100;
            //加载管理部门
            LoadGLBM();
            //加载行政区
            LoadXZQ();
            //加载业务员
            LoadYWY();
            //加载取水用途
            LoadQSYT();
            //加载行业分类
            LoadHYFL();
            //加载流域
            LoadLY();
            //水利分片
            LoadSLFP();
            //水资源分区
            LoadSZYFQ();
        }



        /// <summary>
        /// 加载管理部门
        /// </summary>
        private void LoadGLBM()
        {
            DataTable dt = GLBM.SelectQS_JX_BUMENXXesDynamic("I_JLZT=0 and S_BUMENBH NOT IN(0,600)", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cbmGuanLiBM.Items.Add(dt.Rows[i]["S_BUMENMC"].ToString(), dt.Rows[i]["S_BUMENBH"]);
            }
            cbmGuanLiBM.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载行政区
        /// </summary>
        private void LoadXZQ()
        {
            DataTable dt = XZQ.SelectQS_JX_XINGZHENGQsDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbXingZhengQ.Items.Add(dt.Rows[i]["S_XINGZHENGQM"].ToString(), dt.Rows[i]["S_XINGZHENGQH"]);
            }
        }

        /// <summary>
        /// 加载业务员
        /// </summary>
        private void LoadYWY()
        {
            PageTools.QSLoadCombox(cmbYeWuY, PageTools.eLoadType.业务员QS, null, "");
        }


        /// <summary>
        /// 加载 取水用途
        /// </summary>
        private void LoadQSYT()
        {
            DataTable dt = QSYT.SelectQS_JX_QUSHUIXXesDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbQuShuiYT.Items.Add(dt.Rows[i]["S_QUSHUIMC"].ToString(), dt.Rows[i]["S_QUSHUIBH"]);
            }
            cmbQuShuiYT.Items.Insert(0, new ListEditItem("", "-1"));
        }
        /// <summary>
        /// 加载行业分类
        /// </summary>
        private void LoadHYFL()
        {
            DataTable dt = HYFL.SelectQS_JX_HANGYEFLXXesDynamic("I_JLZT=0", "S_FENLEIBH");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbHangYeLX.Items.Add(dt.Rows[i]["S_FENLEIMC"].ToString(), dt.Rows[i]["S_FENLEIBH"]);
            }
            cmbHangYeLX.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载流域
        /// </summary>
        private void LoadLY()
        {
            DataTable dt = LYXX.SelectQS_JX_LIUYUXXesDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbLiuYu.Items.Add(dt.Rows[i]["S_LIUYUMC"].ToString(), dt.Rows[i]["S_LIUYUBH"]);
            }
            cmbLiuYu.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载水利分片
        /// </summary>
        private void LoadSLFP()
        {
            DataTable dt = SLFP.SelectQS_JX_SHUILIFPXXesDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbShuiLiFP.Items.Add(dt.Rows[i]["S_SHUILIFPMC"].ToString(), dt.Rows[i]["S_SHUILIFPBH"]);
            }
            cmbShuiLiFP.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载水资源分区
        /// </summary>
        private void LoadSZYFQ()
        {
            DataTable dt = SZYFQ.SelectQS_JX_SHUIZIYFQsDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbShuiZiYFQ.Items.Add(dt.Rows[i]["S_SHUIZIYMC"].ToString(), dt.Rows[i]["S_SHUIZIYBH"]);
            }
            cmbShuiZiYFQ.Items.Insert(0, new ListEditItem("", "0"));
        }
        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridData()
        {
            int wtype = BusinessTool.WType;
            int actindex = ASPxPageControl1.ActiveTabIndex;
            try
            {
                if (actindex == 0)
                {
                    int ym = Convert.ToInt32(cmbYear.Value) * 100 + Convert.ToInt32(cmbMonth.Value);
                    int hnhw = cmbHuanNeiHW.Value != null ? Convert.ToInt32(cmbHuanNeiHW.Value) : 0;
                    string xzq = cmbXingZhengQ.Text != "全部" ? cmbXingZhengQ.Value.ToString() : null;
                    string ywy = cmbYeWuY.Value != null && cmbYeWuY.Value.ToString() != "-1" ? cmbYeWuY.Value.ToString() : null;
                    int v_bs = -1;
                    string v_val = null;
                    //1 用户号，2 用户名，3 用户地址，4 取水用途，5 行业类型 ，6 管理部门 ，
                    //7 水价 ，8 流域，9 水利分片，10 水资源分区，11 收费方式，12 开户户名，13 银行帐号
                    if (chkYongHuH.Checked && txtYongHuH.Text != "")
                    {
                        v_bs = 1;
                        v_val = txtYongHuH.Text;
                    }
                    else if (chkYongHuM.Checked && txtYongHuM.Text != "")
                    {
                        v_bs = 2;
                        v_val = txtYongHuM.Text;
                    }
                    else if (chkYongHuDZ.Checked && txtYongHuDZ.Text != "")
                    {
                        v_bs = 3;
                        v_val = txtYongHuDZ.Text;
                    }
                    else if (rabQuShuiYT.Checked && cmbQuShuiYT.Text != "")
                    {
                        v_bs = 4;
                        v_val = cmbQuShuiYT.Value.ToString();
                    }
                    else if (rabHangYeLX.Checked && cmbHangYeLX.Text != "")
                    {
                        v_bs = 5;
                        v_val = cmbHangYeLX.Value.ToString();
                    }
                    else if (rabGuanLiBM.Checked && cbmGuanLiBM.Text != "")
                    {
                        v_bs = 6;
                        v_val = cbmGuanLiBM.Value.ToString();
                    }
                    else if (rabShuiJia.Checked && cmbShuiJia.Text != "" && txtShuiJia.Text != "")
                    {
                        v_bs = 7;
                        v_val = cmbShuiJia.Text + txtShuiJia.Text;
                    }
                    else if (rabLiuYu.Checked && cmbLiuYu.Text != "")
                    {
                        v_bs = 8;
                        v_val = cmbLiuYu.Value.ToString();
                    }
                    else if (rabShuiLiFP.Checked && cmbShuiLiFP.Text != "")
                    {
                        v_bs = 9;
                        v_val = cmbShuiLiFP.Value.ToString();
                    }
                    else if (rabShuiZiYFQ.Checked && cmbShuiZiYFQ.Text != "")
                    {
                        v_bs = 10;
                        v_val = cmbShuiZiYFQ.Value.ToString();
                    }
                    else if (rabShouFeiFS.Checked && cmbShouFeiFS.Text != "")
                    {
                        v_bs = 11;
                        v_val = cmbShouFeiFS.Value.ToString();
                    }
                    else if (rabKaiHuHM.Checked && txtKaiHuHM.Text != "")
                    {
                        v_bs = 12;
                        v_val = txtKaiHuHM.Text;
                    }
                    else if (rabYinHangZH.Checked && txtYinHangZH.Text != "")
                    {
                        v_bs = 13;
                        v_val = txtYinHangZH.Text;
                    }
                    this.dtYongHuXX = _SpHelper.P_QSCX_YONGHUXXCX(wtype, ym, hnhw, xzq, ywy, v_bs, v_val, 0).Tables[0];
                    if (wtype == 1)
                    {
                        gvYongHuXX.Columns.Clear();
                        LoadColumnDate(gvYongHuXX, "S_YONGHUH", "用户号", 60);
                        LoadColumnDate(gvYongHuXX, "S_YONGHUM", "用户名", 200);
                        LoadColumnDate(gvYongHuXX, "S_DIZHI", "用户地址", 200);
                        LoadColumnDate(gvYongHuXX, "S_XINGZHENGQBH", "行政区号", 70);
                        LoadColumnDate(gvYongHuXX, "S_XINGZHENGQM", "行政区名", 70);
                        LoadColumnDate(gvYongHuXX, "S_YEWUY", "业务员", 60);
                        LoadColumnDate(gvYongHuXX, "S_LIUYUMC", "流域", 50);
                        LoadColumnDate(gvYongHuXX, "S_SHUIZIYMC", "水资源分区", 80);
                        LoadColumnDate(gvYongHuXX, "S_SHUILIFPMC", "水利分片", 80);
                        LoadColumnDate(gvYongHuXX, "HNHW", "环内环外", 70);
                        LoadColumnDate(gvYongHuXX, "S_QUSHUIMC", "取水用途", 80);
                        LoadColumnDate(gvYongHuXX, "S_FENLEIMC", "行业分类", 80);
                        LoadColumnDate(gvYongHuXX, "N_SHUIJIA", "水价", 60, "0.00");
                        LoadColumnDate(gvYongHuXX, "S_YOUBIAN", "邮政编码", 80);
                        LoadColumnDate(gvYongHuXX, "S_LIANXIR", "联系人", 90);
                        LoadColumnDate(gvYongHuXX, "S_DIANHUA", "联系电话", 100);
                        LoadColumnDate(gvYongHuXX, "S_LIANXIBM", "联系部门", 100);
                        LoadColumnDate(gvYongHuXX, "S_KAIHUHM", "开户户名", 200);
                        LoadColumnDate(gvYongHuXX, "S_KAIHUH", "银行帐号", 200);
                        LoadColumnDate(gvYongHuXX, "S_KAIHUYH", "开户银行", 200);
                        LoadColumnDate(gvYongHuXX, "JS", "取水口数", 50);
                        LoadColumnDate(gvYongHuXX, "BS", "表数", 50);
                        LoadColumnDate(gvYongHuXX, "D_TIANJIARQ", "开户日期", 80, "yyyy-MM-dd");
                        LoadColumnDate(gvYongHuXX, "S_HETONGH", "合同号", 280);
                        LoadColumnDate(gvYongHuXX, "S_ZHUSHI", "备注", 200);

                    }
                    else
                    {
                        gvYongHuXX.Columns.Clear();
                        LoadColumnDate(gvYongHuXX, "S_YONGHUH", "用户号", 60);
                        LoadColumnDate(gvYongHuXX, "S_YONGHUM", "用户名", 200);
                        LoadColumnDate(gvYongHuXX, "S_DIZHI", "用户地址", 200);
                        LoadColumnDate(gvYongHuXX, "S_XINGZHENGQBH", "行政区号", 70);
                        LoadColumnDate(gvYongHuXX, "S_XINGZHENGQM", "行政区名", 70);
                        LoadColumnDate(gvYongHuXX, "S_YEWUY", "业务员", 60);
                        LoadColumnDate(gvYongHuXX, "S_BUMENBH", "部门编号", 10);
                        LoadColumnDate(gvYongHuXX, "S_BUMENMC", "管理部门", 130);
                        LoadColumnDate(gvYongHuXX, "S_LIUYUMC", "流域", 50);
                        LoadColumnDate(gvYongHuXX, "S_SHUIZIYMC", "水资源分区", 80);
                        LoadColumnDate(gvYongHuXX, "S_SHUILIFPMC", "水利分片", 80);
                        LoadColumnDate(gvYongHuXX, "HNHW", "环内环外", 70);
                        LoadColumnDate(gvYongHuXX, "S_QUSHUIMC", "取水用途", 80);
                        LoadColumnDate(gvYongHuXX, "S_FENLEIMC", "行业分类", 80);
                        LoadColumnDate(gvYongHuXX, "N_SHUIJIA", "水价", 60, "0.00");
                        LoadColumnDate(gvYongHuXX, "S_YOUBIAN", "邮政编码", 80);
                        LoadColumnDate(gvYongHuXX, "S_LIANXIR", "联系人", 90);
                        LoadColumnDate(gvYongHuXX, "S_DIANHUA", "联系电话", 100);
                        LoadColumnDate(gvYongHuXX, "S_LIANXIBM", "联系部门", 100);
                        LoadColumnDate(gvYongHuXX, "SFFS", "收费方式", 60);
                        LoadColumnDate(gvYongHuXX, "S_KAIHUHM", "开户户名", 200);
                        LoadColumnDate(gvYongHuXX, "S_KAIHUH", "银行帐号", 200);
                        LoadColumnDate(gvYongHuXX, "S_KAIHUYH", "开户银行", 200);
                        LoadColumnDate(gvYongHuXX, "JS", "井数", 50);
                        LoadColumnDate(gvYongHuXX, "BS", "表数", 50);
                        LoadColumnDate(gvYongHuXX, "D_TIANJIARQ", "开户日期", 80, "yyyy-MM-dd");
                        LoadColumnDate(gvYongHuXX, "S_HETONGH", "合同号", 280);
                        LoadColumnDate(gvYongHuXX, "S_ZHUSHI", "备注", 200);
                    }



                    gvYongHuXX.DataSource = this.dtYongHuXX;
                    gvYongHuXX.DataBind();
                    if (this.dtYongHuXX != null && this.dtYongHuXX.Rows.Count > 0)
                    {
                        zjl.Text = "共" + this.dtYongHuXX.Rows.Count.ToString() + "条";
                        gvYongHuXX.FocusedRowIndex = 0;
                        SetData();
                    }
                }
                else if (actindex == 1)
                {
                    BindQuanNian();
                }
                else if (actindex == 2)
                {
                    BindYue();
                }
                else if (actindex == 3)
                {
                    BindYueHZ();
                }
                else if (actindex == 4)
                {
                    BindSFXX();
                }
                else if (actindex == 5)
                {
                    BindQNSFCX();
                }
                else if (actindex == 6)
                {
                    BindYWYSFCX();
                }
            }
            catch (Exception ex)
            {

            }

        }
        #region 全年情况查询

        private Dictionary<string, string> getConditions()
        {
            Dictionary<string, string> list = new Dictionary<string, string>();
            list.Add("y", cmbYear.Value.ToString());
            list.Add("m", this.cmbMonth.Value.ToString());
            list.Add("xingzhengq", this.cmbXingZhengQ.SelectedIndex <= 0 ? null : Convert.ToString(this.cmbXingZhengQ.Value));
            list.Add("ywy", this.cmbYeWuY.SelectedIndex <= 0 ? null : cmbYeWuY.Value.ToString());
            list.Add("yhh", this.chkYongHuH.Checked?txtYongHuH.Text:null);
            list.Add("yhm", this.chkYongHuM.Checked?txtYongHuM.Text:null);
            list.Add("dizhi", this.chkYongHuDZ.Checked?txtYongHuDZ.Text:null);
            list.Add("bumen", this.rabGuanLiBM.Checked?(cbmGuanLiBM.Value == null ? null : cbmGuanLiBM.Value.ToString()):null);
            list.Add("shuijia", this.rabShuiJia.Checked?txtShuiJia.Text:null);
            list.Add("qushuiyt", this.rabQuShuiYT.Checked?(cmbQuShuiYT.SelectedIndex <= 0 ? null : cmbQuShuiYT.Value.ToString()):null);
            list.Add("hangyelx", this.rabHangYeLX.Checked?(cmbHangYeLX.SelectedIndex <= 0 ? null : cmbHangYeLX.Value.ToString()):null);
            list.Add("huanxianbj", this.cmbHuanNeiHW.SelectedIndex <= 0 ? null : cmbHuanNeiHW.Value.ToString().Trim());
            list.Add("shoufeifs", this.rabShouFeiFS.Checked?(this.cmbShouFeiFS.SelectedIndex <= 0 ? "-1" : Convert.ToString(rabShouFeiFS.Value)):null);
            list.Add("kaihuhm", this.rabKaiHuHM.Checked?txtKaiHuHM.Text:null);
            list.Add("kaihuzh", this.rabYinHangZH.Checked?txtYinHangZH.Text:null);
            list.Add("liuyu", this.rabLiuYu.Checked?(this.cmbLiuYu.SelectedIndex <= 0 ? null : Convert.ToString(cmbLiuYu.Value)):null);
            list.Add("shuiziyfq", this.rabShuiZiYFQ.Checked?(this.cmbShuiZiYFQ.SelectedIndex <= 0 ? null : Convert.ToString(cmbShuiZiYFQ.Value)):null);
            list.Add("shuilifp", this.rabShuiLiFP.Checked?(this.cmbShuiLiFP.SelectedIndex <= 0 ? null : Convert.ToString(cmbShuiLiFP.Value)):null);
            return list;
        }
        private void BindQuanNian()
        {
            /*
            //DataSet ds = _SpHelper.P_QS_CX_QUANNIANQKCX();
            int v_iwatertype = BusinessTool.WType;
            
            int year = Convert.ToInt32(cmbYear.Value.ToString()) ;
            string xingzhengq = this.cmbXingZhengQ.SelectedIndex <= 0 ? null : Convert.ToString(this.cmbXingZhengQ.Value);
            string ywy = this.cmbYeWuY.SelectedIndex <= 0 ? null : cmbYeWuY.Value.ToString();
            string yhh = txtYongHuH.Text;
            string yhm = txtYongHuM.Text;
            string dizhi = txtYongHuDZ.Text;
            string xukezhengh = "";//--许可证
            string bumen = cbmGuanLiBM.Value == null ? null : cbmGuanLiBM.Value.ToString();//公司号
            string shuijia = txtShuiJia.Text;//水价
            string qushuiyt = cmbQuShuiYT.SelectedIndex <= 0 ? null : cmbQuShuiYT.Value.ToString();//, -- 取水用途
            //string shuilianglb = "";//VARCHAR2, --水量类别

            string hangyelx = cmbHangYeLX.SelectedIndex <= 0 ? null : cmbHangYeLX.Value.ToString();// VARCHAR2, -- 行业类别
            string huanxianbj = this.cmbHuanNeiHW.SelectedIndex <= 0 ? null : cmbHuanNeiHW.Value.ToString().Trim();//  VARCHAR2, -- 环外环内

            int shoufeifs = this.cmbShouFeiFS.SelectedIndex <= 0 ? -1 : Convert.ToInt32(rabShouFeiFS.Value);//       INT, -- 收费方式：0 - 不托收；1 - 托收
            string kaihuhm = txtKaiHuHM.Text;//      VARCHAR2, -- 开户户名
            string kaihuzh = txtYinHangZH.Text;//        VARCHAR2, -- 开户帐号
            string liuyu = this.cmbLiuYu.SelectedIndex <= 0 ? null: Convert.ToString(cmbLiuYu.Value);//     VARCHAR2, --流域
            string shuiziyfq = this.cmbShuiZiYFQ.SelectedIndex <= 0 ? null : Convert.ToString(cmbShuiZiYFQ.Value); //  VARCHAR2, --水资源分区
            string shuilifp = this.cmbShuiLiFP.SelectedIndex <= 0 ? null : Convert.ToString(cmbShuiLiFP.Value);//, --水利分片
            */
            //string kaihuyh = "";// VARCHAR2, -- 开户银行 

            //DataSet ds = SearchSpHelper.P_QS_CX_QUANNIANQKCX(v_iwatertype, "", "", "", year, month, V_SCANTONGUID, V_SBUSIMANGUID, V_SID, V_SNAME, V_SADDR, V_SLICENSEID, 
            //    V_SCOMPANYGUID, V_SWPRICE, V_SWUSAGEGUID, V_SWELLID, V_SWELLADDR, V_ILAYER, V_SWELLTYPE, V_SWELLFLAG, V_SWATERNUMBER, V_SWATERAMOUNTTYPE, V_MONTH, 
            //    V_SINDUSTRYGUID, V_ICIRCLELINE, V_ICONSIGN, V_SBANKNAME, V_SBANKID, V_VALLEYGUID, V_WATERAREAGUID, V_WATERAREAGUID, V_SACCOUNTBANK);
            DataTable dt = null;
            gvGrid1Tab2.Columns.Clear();
            Dictionary<string, string> clist = this.getConditions();
            if (BusinessTool.WType == 2)
            {
                dt = SearchSpHelper.P_QS_CX_QUANNIANQKCX_DXS(0, Convert.ToInt32(clist["y"]), clist["xingzhengq"], clist["ywy"], clist["yhh"], clist["yhm"], clist["dizhi"], clist["bumen"], clist["shuijia"], clist["qushuiyt"], clist["hangyelx"], clist["huanxianbj"],clist["shoufeifs"]==null?-1:Convert.ToInt32(clist["shoufeifs"]), clist["kaihuhm"], clist["kaihuzh"], clist["liuyu"], clist["shuiziyfq"], clist["shuilifp"]).Tables[0];
                LoadColumnDate(gvGrid1Tab2, "S_YONGHUH", "用户号", 80);
                LoadColumnDate(gvGrid1Tab2, "S_YONGHUM", "用户名", 200);
                LoadColumnDate(gvGrid1Tab2, "I1", "普通采", 90);
                LoadColumnDate(gvGrid1Tab2, "I2", "矿泉采", 90);
                LoadColumnDate(gvGrid1Tab2, "I3", "采灌采", 100);
                LoadColumnDate(gvGrid1Tab2, "I0", "开采量", 100);
                LoadColumnDate(gvGrid1Tab2, "J1", "采灌灌", 100);
                LoadColumnDate(gvGrid1Tab2, "J2", "专灌", 100);
                LoadColumnDate(gvGrid1Tab2, "J0", "回灌量", 120);
                LoadColumnDate(gvGrid1Tab2, "K0", "总水量", 100);
                LoadColumnDate(gvGrid1Tab2, "N0", "深井水费", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "L1", "开采计划", 100);
                //LoadColumnDate(gvGrid1Tab2, "J4", "回灌计划", 100);
                LoadColumnDate(gvGrid1Tab2, "L2", "采灌采计划", 100);
                LoadColumnDate(gvGrid1Tab2, "L3", "采灌灌计划", 100);
                LoadColumnDate(gvGrid1Tab2, "S_TEXT3", "行政区", 100);

                LoadColumnDate(gvGrid1Tab2, "L4", "现计划", 100);
                LoadColumnDate(gvGrid1Tab2, "L5", "超计划", 100);
                LoadColumnDate(gvGrid1Tab2, "L6", "加价调整", 100);
                LoadColumnDate(gvGrid1Tab2, "L7", "加价", 100);
                LoadColumnDate(gvGrid1Tab2, "M3", "超计划金额", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "M4", "加价额", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "N0", "深井水费", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "M1", "开采完成率", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "M2", "回灌完成率", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "M5", "超计划率", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "M6", "加价", 100, "0.00");
            }
            else
            {
                dt = SearchSpHelper.P_QS_CX_QUANNIANQKCX_DBS(0, Convert.ToInt32(clist["y"]), clist["xingzhengq"], clist["ywy"], clist["yhh"], clist["yhm"], clist["dizhi"], clist["bumen"], clist["shuijia"], clist["qushuiyt"], clist["hangyelx"], clist["huanxianbj"], clist["shoufeifs"] == null ? -1 : Convert.ToInt32(clist["shoufeifs"]), clist["kaihuhm"], clist["kaihuzh"], clist["liuyu"], clist["shuiziyfq"], clist["shuilifp"]).Tables[0];
                LoadColumnDate(gvGrid1Tab2, "S_YONGHUH", "用户号", 80);
                LoadColumnDate(gvGrid1Tab2, "S_YONGHUM", "用户名", 200);
                LoadColumnDate(gvGrid1Tab2, "S_HANGYEFLMC", "行业分类", 90);
                LoadColumnDate(gvGrid1Tab2, "I1", "取水量", 90);
                LoadColumnDate(gvGrid1Tab2, "I2", "开账水量", 100);
                LoadColumnDate(gvGrid1Tab2, "I3", "发电量", 100);
                LoadColumnDate(gvGrid1Tab2, "I4", "开账电量", 100);
                LoadColumnDate(gvGrid1Tab2, "N0", "金额", 100, "0.00");
                LoadColumnDate(gvGrid1Tab2, "S_XINGZHENGQBH", "行政区号", 120);
                LoadColumnDate(gvGrid1Tab2, "S_XINGZHENGQM", "行政区名", 120);
                LoadColumnDate(gvGrid1Tab2, "S_QUSHUIYTMC", "取水用途", 100);
                LoadColumnDate(gvGrid1Tab2, "S_SHOUFEIBZ", "收费标准", 100);
                LoadColumnDate(gvGrid1Tab2, "S_HUANXIANBJ", "环内环外", 100);
                LoadColumnDate(gvGrid1Tab2, "S_LIUYUMC", "流域", 100);
                LoadColumnDate(gvGrid1Tab2, "S_SHUIZIYMC", "水资源分区", 100);
                LoadColumnDate(gvGrid1Tab2, "S_SHUILIFPMC", "水利分片", 100);
            }
            dtGridTab2_1 = dt;
            gvGrid1Tab2.DataSource = dtGridTab2_1;
            gvGrid1Tab2.DataBind();
            this.lsCountQN.InnerText = "共"+(dt.Rows.Count-1).ToString()+"条数据";
            gvGrid1Tab2.FocusedRowIndex = 0;
            string yonghuh = Convert.ToString(this.gvGrid1Tab2.GetRowValues(this.gvGrid1Tab2.FocusedRowIndex, "S_YONGHUH"));
            loadQuanNian2(yonghuh);
        }
        // public string GetXianJiHua(object kaicai, object caiguan)
        // {
        //     int jh = 0;
        //     if (Convert.ToInt32(kaicai) > 0)
        //     {
        //         jh = Convert.ToInt32(kaicai);
        //     }
        //     if (Convert.ToInt32(caiguan) > 0)
        //     {
        //         jh = Convert.ToInt32(caiguan);
        //     }
        //     return jh.ToString();
        // }
        ///// <summary>
        ///// 加价调整量
        ///// </summary>
        ///// <param name="kaicai"></param>
        ///// <param name="xianjihua"></param>
        ///// <param name="qushuiyongtu"></param>
        ///// <returns></returns>
        // public int GetChaoJiHua(object kaicai, object xianjihua,object qushuiyongtu)
        // {
        //     double jh = 0;
        //     int kaicaijh = Convert.ToInt32(kaicai);
        //     int xianjih = Convert.ToInt32(xianjihua);
        //     if (qushuiyongtu.ToString() == "公共供水" && kaicaijh - 1.05 * xianjih > 0)
        //     {
        //         jh = kaicaijh - 1.05 * xianjih;
        //     }
        //     else if (qushuiyongtu.ToString() != "公共供水" && kaicaijh - xianjih > 0)
        //     { 
        //         jh = kaicaijh - xianjih;
        //     }
        //     return Convert.ToInt32(jh);
        // }
        // /// <summary>
        // /// 超计划金额
        // /// </summary>
        // /// <param name="jiajial"></param>
        // /// <param name="jiage"></param>
        // /// <param name="beilv"></param>
        // /// <returns></returns>
        // public decimal GetJiaJiaJE(int jiajial,decimal jiage,decimal beilv)
        // {
        //     return jiajial * jiage * beilv;
        // }
        protected void BtnQN2_Click(object sender, EventArgs e)
        {
           // string yonghuh = Convert.ToString(this.gvGrid1Tab2.GetRowValues(this.gvGrid1Tab2.FocusedRowIndex, "S_YONGHUH"));
            //loadQuanNian2(yonghuh);
        }

        private void loadQuanNian2(string yonghuh)
        {
            //string yonghuh = Convert.ToString(this.gvGrid1Tab2.GetRowValues(this.gvGrid1Tab2.FocusedRowIndex, "S_YONGHUH"));
            DataTable dt = null;
            if (string.IsNullOrEmpty(yonghuh))
            {
                return;
            }
            yonghuh = string.IsNullOrEmpty(yonghuh) ? null : yonghuh;
            if (BusinessTool.WType == 2)
            {
                dt = SearchSpHelper.P_QS_CX_QUANNIANQKCX_DXS(1, Convert.ToInt32(this.cmbYear.Value), null, null, yonghuh, null, null, null, null, null, null, null, null, null, null, null, null, null).Tables[0];
                gvGrid2Tab2.Columns.Clear();
                LoadColumnDate(gvGrid2Tab2, "S_M", "月份", 80);
                LoadColumnDate(gvGrid2Tab2, "I1", "普通采", 90);
                LoadColumnDate(gvGrid2Tab2, "I2", "矿泉采", 90);
                LoadColumnDate(gvGrid2Tab2, "I3", "采灌采", 100);
                LoadColumnDate(gvGrid2Tab2, "I0", "开采量", 100);
                LoadColumnDate(gvGrid2Tab2, "J1", "采灌灌", 100);
                LoadColumnDate(gvGrid2Tab2, "J2", "专灌", 100);
                LoadColumnDate(gvGrid2Tab2, "J0", "回灌量", 120);
                LoadColumnDate(gvGrid2Tab2, "N0", "深井水费", 100, "0.00");
            }
            else
            {
                dt = SearchSpHelper.P_QS_CX_QUANNIANQKCX_DBS(1, Convert.ToInt32(this.cmbYear.Value), null, null, yonghuh, null, null, null, null, null, null, null, null, null, null, null, null, null).Tables[0];
                gvGrid2Tab2.Columns.Clear();
                LoadColumnDate(gvGrid2Tab2, "S_M", "月份", 80);
                LoadColumnDate(gvGrid2Tab2, "I1", "取水量", 90);
                LoadColumnDate(gvGrid2Tab2, "I2", "开账水量", 100);
                LoadColumnDate(gvGrid2Tab2, "I3", "发电量", 100);
                LoadColumnDate(gvGrid2Tab2, "I4", "开账电量", 100);
                LoadColumnDate(gvGrid2Tab2, "N0", "金额", 100, "0.00");
            }
            dtGridTab2_2 = dt;
            gvGrid2Tab2.DataSource = dtGridTab2_2;
            gvGrid2Tab2.DataBind();
        }
        #endregion

        #region 月汇总
        private void BindYueHZ()
        {
            int wtype = BusinessTool.WType;
            int year = Convert.ToInt32(cmbYear.Value.ToString());
            int month = Convert.ToInt32(cmbMonth.Value.ToString());

            string huanxian = cmbHuanNeiHW.SelectedIndex<=0  ? "0" : cmbHuanNeiHW.Value.ToString();
            string xingzhengqu = cmbXingZhengQ.SelectedIndex <= 0 ? "" : cmbXingZhengQ.Value.ToString();

            string yewuy = cmbYeWuY.SelectedIndex <= 0 ? "" : cmbYeWuY.Value.ToString();
            string yonghuh = txtYongHuH.Text;
            string yonghum = txtYongHuM.Text;
            string dizhi = txtYongHuDZ.Text;
            string yongshuiyt = cmbQuShuiYT.SelectedIndex <= 0 ? "" : cmbQuShuiYT.Value.ToString();
            string hangyelx = cmbHangYeLX.SelectedIndex <= 0 ? "" : cmbHangYeLX.Value.ToString();
            string bumen = cbmGuanLiBM.SelectedIndex <= 0 ? "" : cbmGuanLiBM.Value.ToString();
            string shuijiatj = cmbShuiJia.SelectedIndex <= 0 ? "" : cmbShuiJia.Value.ToString();
            string shuijia = txtShuiJia.Text;
            string liuyu = cmbLiuYu.SelectedIndex <= 0 ? "" : cmbLiuYu.Value.ToString();
            string fenpian = cmbShuiLiFP.SelectedIndex <= 0 ? "" : cmbShuiLiFP.Value.ToString();
            string shuiziyfq = cmbShuiZiYFQ.SelectedIndex <= 0 ? "" : cmbShuiZiYFQ.Value.ToString();
            string shoufeifs = cmbShouFeiFS.SelectedIndex <= 0 ? "" : cmbShouFeiFS.Value.ToString();
            string kaihuhum = txtKaiHuHM.Text;
            string yinhangzh = txtYinHangZH.Text;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (xingzhengqu != "" && xingzhengqu != "0")
            {
                sb.AppendFormat(" and YH.S_XINGZHENGQBH='{0}'", xingzhengqu);
            }
            if (huanxian != "0")
            {
                sb.AppendFormat(" and YH.S_HUANXIANBJ='{0}'", huanxian);
            }
            if (yewuy != "")
            {
                sb.AppendFormat(" and YH.S_YEWUY='{0}'", yewuy);
            }
            if (yonghuh != "")
            {
                sb.AppendFormat(" and YH.S_YONGHUH like '%{0}%'", yonghuh);
            }
            if (yonghum != "")
            {
                sb.AppendFormat(" and YH.S_YONGHUM like '%{0}%'", yonghum);
            }
            if (dizhi != "")
            {
                sb.AppendFormat(" and YH.S_DIZHI like '%{0}%'", dizhi);
            }
            if (yongshuiyt != "")
            {
                sb.AppendFormat(" and YH.S_QUSHUIYTBH='{0}'", yongshuiyt);
            }
            if (hangyelx != "")
            {
                sb.AppendFormat(" and YH.S_HANGYEBH='{0}'", hangyelx);
            }
            if (bumen != "")
            {
                sb.AppendFormat(" and YH.S_BUMENBH='{0}'", bumen);
            }
            double sj = 0;
            if (shuijiatj != "" && shuijia != "" && double.TryParse(shuijia, out sj))
            {
                sb.AppendFormat(" and YH.N_SHUIJIA={0}{1}", shuijiatj, shuijia);
            }
            if (liuyu != "")
            {
                sb.AppendFormat(" and YH.S_LIUYUBH='{0}'", liuyu);
            }
            if (fenpian != "")
            {
                sb.AppendFormat(" and YH.S_FENPIANBH='{0}'", fenpian);
            }
            if (shuiziyfq != "")
            {
                sb.AppendFormat(" and YH.S_SHUIZIYBH='{0}'", shuiziyfq);
            }
            if (shoufeifs != "")
            {
                sb.AppendFormat(" and YH.I_BIAOSHI='{0}'", shoufeifs);
            }
            if (kaihuhum != "")
            {
                sb.AppendFormat(" and YH.S_KAIHUHM='{0}'", kaihuhum);
            }
            if (yinhangzh != "")
            {
                sb.AppendFormat(" and YH.S_KAIHUH='{0}'", yinhangzh);
            }
            var count = gvGridTab3.Columns.Count;
            while (gvGridTab4.Columns.Count > 0)
            {
                gvGridTab4.Columns.RemoveAt(0);
            }

            //DataSet ds = SearchSpHelper.P_QS_CX_QUANNIANCXYGZ(BusinessTool.WType, year, month, sb.ToString(), cmbHuiZonglx.SelectedIndex);
            //if (ds.Tables[0] != null)
            //{
            //    foreach (DataColumn d in ds.Tables[0].Columns)
            //    {

            //        GridViewDataTextColumn c = new GridViewDataTextColumn();
            //        c.FieldName = d.ColumnName;
            //        c.Caption = d.ColumnName;

            //        gvGridTab4.Columns.Add(c);
            //    }
            //}
            DataTable dt = _SpHelper.P_QS_CX_QUANNIANCXYHZ(wtype, year, month, sb.ToString(), cmbHuiZonglx.SelectedIndex).Tables[0];
            gvGridTab4.Columns.Clear();
            if (wtype == 1)
            {
                LoadColumnDate(gvGridTab4, "BH", "编号", 50);
                LoadColumnDate(gvGridTab4, "MC", "名称", 150);
                LoadColumnDate(gvGridTab4, "HS", "户数", 60);
                LoadColumnDate(gvGridTab4, "BS", "表数", 60);
                LoadColumnDate(gvGridTab4, "QSL", "取水量", 90);
                LoadColumnDate(gvGridTab4, "KZSL", "开帐水量", 100, "0.00");
                LoadColumnDate(gvGridTab4, "KZJE", "开帐金额", 100, "0.00");
                LoadColumnDate(gvGridTab4, "DL", "月发电量", 100);
                LoadColumnDate(gvGridTab4, "KZDL", "开账电量", 80);

            }
            else
            {
                LoadColumnDate(gvGridTab4, "BH", "编号", 80);
                LoadColumnDate(gvGridTab4, "MC", "名称", 50);
                LoadColumnDate(gvGridTab4, "HS", "户数", 90);
                LoadColumnDate(gvGridTab4, "BS", "表数", 90);
                LoadColumnDate(gvGridTab4, "PTC", "普通采", 90);
                LoadColumnDate(gvGridTab4, "KQC", "矿泉采", 90);
                LoadColumnDate(gvGridTab4, "CGC", "采灌采", 90);
                LoadColumnDate(gvGridTab4, "KCL", "开采量", 90);
                LoadColumnDate(gvGridTab4, "CGG", "采灌灌", 90);
                LoadColumnDate(gvGridTab4, "ZG", "专灌", 90);
                LoadColumnDate(gvGridTab4, "HGL", "回灌量", 90);
                LoadColumnDate(gvGridTab4, "ZSL", "总水量", 90);
                LoadColumnDate(gvGridTab4, "KCJH", "开采计划", 90);
                LoadColumnDate(gvGridTab4, "HGJH", "回灌计划", 90);
                LoadColumnDate(gvGridTab4, "KZJE", "开账金额", 90, "0.00");
                LoadColumnDate(gvGridTab4, "SZYF", "水资源费", 90, "0.00");
            }
            dtGridTab4 = dt;
            gvGridTab4.DataSource = dtGridTab4;
            gvGridTab4.DataBind();
            zjltab4.Text = "共" + (gvGridTab4.VisibleRowCount - 1) + "条";
        }
        #endregion

        #region 月查询

        private void BindYue()
        {
            int wtype = BusinessTool.WType;
            int year = Convert.ToInt32(cmbYear.Value.ToString());
            int month = Convert.ToInt32(cmbMonth.Value.ToString());

            string huanxian = cmbHuanNeiHW.SelectedIndex <= 0 ? "0" : cmbHuanNeiHW.Value.ToString();
            string xingzhengqu = cmbXingZhengQ.SelectedIndex <= 0 ? "" : cmbXingZhengQ.Value.ToString();

            string yewuy = cmbYeWuY.SelectedIndex <= 0 ? "" : cmbYeWuY.Value.ToString();
            string yonghuh = txtYongHuH.Text;
            string yonghum = txtYongHuM.Text;
            string dizhi = txtYongHuDZ.Text;
            string yongshuiyt = cmbQuShuiYT.SelectedIndex <= 0 ? "" : cmbQuShuiYT.Value.ToString();
            string hangyelx = cmbHangYeLX.SelectedIndex <= 0 ? "" : cmbHangYeLX.Value.ToString();
            string bumen = cbmGuanLiBM.SelectedIndex <= 0 ? "" : cbmGuanLiBM.Value.ToString();
            string shuijiatj = cmbShuiJia.SelectedIndex <= 0 ? "" : cmbShuiJia.Text.ToString();
            string shuijia = txtShuiJia.Text;
            string liuyu = cmbLiuYu.SelectedIndex <= 0 ? "" : cmbLiuYu.Value.ToString();
            string fenpian = cmbShuiLiFP.SelectedIndex <= 0 ? "" : cmbShuiLiFP.Value.ToString();
            string shuiziyfq = cmbShuiZiYFQ.SelectedIndex <= 0 ? "" : cmbShuiZiYFQ.Value.ToString();
            string shoufeifs = cmbShouFeiFS.SelectedIndex <= 0 || cmbShouFeiFS.Value.ToString() == "-1" ? "" : cmbShouFeiFS.Value.ToString();
            string kaihuhum = txtKaiHuHM.Text;
            string yinhangzh = txtYinHangZH.Text;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (xingzhengqu != "" && xingzhengqu != "0")
            {
                sb.AppendFormat(" and YH.S_XINGZHENGQBH='{0}'", xingzhengqu);
            }
            if (huanxian != "0")
            {
                sb.AppendFormat(" and YH.S_HUANXIANBJ='{0}'", huanxian);
            }
            if (yewuy != "")
            {
                sb.AppendFormat(" and YH.S_YEWUY='{0}'", yewuy);
            }
            if (yonghuh != "")
            {
                sb.AppendFormat(" and YH.S_YONGHUH like '%{0}%'", yonghuh);
            }
            if (yonghum != "")
            {
                sb.AppendFormat(" and YH.S_YONGHUM like '%{0}%'", yonghum);
            }
            if (dizhi != "")
            {
                sb.AppendFormat(" and YH.S_DIZHI like '%{0}%'", dizhi);
            }
            if (yongshuiyt != "")
            {
                sb.AppendFormat(" and YH.S_QUSHUIYTBH='{0}'", yongshuiyt);
            }
            if (hangyelx != "")
            {
                sb.AppendFormat(" and YH.S_HANGYEBH='{0}'", hangyelx);
            }
            if (bumen != "")
            {
                sb.AppendFormat(" and YH.S_BUMENBH='{0}'", bumen);
            }
            double sj = 0;
            if (shuijiatj != "" && shuijia != "" && double.TryParse(shuijia, out sj))
            {
                sb.AppendFormat(" and YH.N_SHUIJIA{0}{1}", shuijiatj, shuijia);
            }
            if (liuyu != "")
            {
                sb.AppendFormat(" and YH.S_LIUYUBH='{0}'", liuyu);
            }
            if (fenpian != "")
            {
                sb.AppendFormat(" and YH.S_FENPIANBH='{0}'", fenpian);
            }
            if (shuiziyfq != "")
            {
                sb.AppendFormat(" and YH.S_SHUIZIYBH='{0}'", shuiziyfq);
            }
            if (shoufeifs != "")
            {
                sb.AppendFormat(" and YH.I_BIAOSHI='{0}'", shoufeifs);
            }
            if (kaihuhum != "")
            {
                sb.AppendFormat(" and YH.S_KAIHUHM='{0}'", kaihuhum);
            }
            if (yinhangzh != "")
            {
                sb.AppendFormat(" and YH.S_KAIHUH='{0}'", yinhangzh);
            }


            DataTable dt = _SpHelper.P_QS_CX_QUANNIANYCX(wtype, year, month, sb.ToString()).Tables[0];
            if (dt != null)
            {
                //var count = gvGridTab3.Columns.Count;
                //while (gvGridTab3.Columns.Count > 0)
                //{
                //    gvGridTab3.Columns.RemoveAt(0);
                //}
                //foreach (DataColumn d in dt.Columns)
                //{
                //    GridViewDataTextColumn c = new GridViewDataTextColumn();
                //    c.FieldName = d.ColumnName;
                //    c.Caption = d.ColumnName;

                //    gvGridTab3.Columns.Add(c);
                //}
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                gvGridTab3.Columns.Clear();
                if (wtype == 1)
                {
                    LoadColumnDate(gvGridTab3, "S_YONGHUH", "用户号", 80);
                    LoadColumnDate(gvGridTab3, "S_YONGHUM", "用户名", 200);
                    LoadColumnDate(gvGridTab3, "N_SHUIJIA", "单价", 50,"0.00");
                    LoadColumnDate(gvGridTab3, "QSL", "取水量", 90);
                    LoadColumnDate(gvGridTab3, "KZSL", "开帐水量", 100);
                    LoadColumnDate(gvGridTab3, "KZSLJE", "开帐金额", 100, "0.00");
                    //LoadColumnDate(gvGridTab3, "KZDLJE", "月发电量", 100);
                    //LoadColumnDate(gvGridTab3, "KZDL", "开账电量", 100);
                    //replaced by guodengjie
                    LoadColumnDate(gvGridTab3, "KZDL", "月发电量", 70);
                    LoadColumnDate(gvGridTab3, "KZDLJE", "开账电量", 70);
                    //LoadColumnDate(gvGridTab3, "S_BUMENMC", "主管部门", 120);
                    LoadColumnDate(gvGridTab3, "S_QUSHUIMC", "取水用途", 100);
                    LoadColumnDate(gvGridTab3, "SFBZ", "收费标准", 90);
                }
                else
                {
                    LoadColumnDate(gvGridTab3, "S_YONGHUH", "用户号", 80);
                    LoadColumnDate(gvGridTab3, "S_YONGHUM", "用户名", 200);
                    LoadColumnDate(gvGridTab3, "PTC", "普通采", 90);
                    LoadColumnDate(gvGridTab3, "KQC", "矿泉采", 90);
                    LoadColumnDate(gvGridTab3, "CGC", "采灌采", 90);
                    LoadColumnDate(gvGridTab3, "KCL", "开采量", 90);
                    LoadColumnDate(gvGridTab3, "CGG", "采灌灌", 90);
                    LoadColumnDate(gvGridTab3, "ZG", "专灌", 90);
                    LoadColumnDate(gvGridTab3, "HGL", "回灌量", 90);
                    LoadColumnDate(gvGridTab3, "ZSL", "总水量", 90);
                    LoadColumnDate(gvGridTab3, "S_BUMENMC", "主管部门", 150);
                    LoadColumnDate(gvGridTab3, "S_QUSHUIMC", "取水用途", 100);
                    LoadColumnDate(gvGridTab3, "SJSF", "深井水费", 90,"0.00");
                    LoadColumnDate(gvGridTab3, "N_SHUIJIA", "单价", 90, "0.00");
                }
            }
            dtGridTab3 = dt;
            gvGridTab3.DataSource = dtGridTab3;
            gvGridTab3.DataBind();

            yuePage.InnerText = "共" + (gvGridTab3.VisibleRowCount - 1) + "条数据";

        }

        #endregion

        #region 用户收费情况
        private void BindSFXX()
        {
            this.dtSource5_1 = null;
            gvGrid1Tab5.Columns.Clear();
            Dictionary<string, string> clist = this.getConditions();
            this.dtSource5_1 = SearchSpHelper.P_QS_CX_YONGHUSFQK(BusinessTool.WType, 0, Convert.ToInt32(clist["y"]), Convert.ToInt32(clist["m"]), clist["xingzhengq"], clist["ywy"], clist["yhh"], clist["yhm"], clist["dizhi"], clist["bumen"], clist["shuijia"], clist["qushuiyt"], clist["hangyelx"], clist["huanxianbj"], Convert.ToInt32(clist["shoufeifs"]), clist["kaihuhm"], clist["kaihuzh"], clist["liuyu"], clist["shuiziyfq"], clist["shuilifp"]).Tables[0];
            LoadColumnDate(gvGrid1Tab5, "S_YONGHUH", "用户号", 80);
            LoadColumnDate(gvGrid1Tab5, "S_YONGHUM", "用户名", 200);
            LoadColumnDate(gvGrid1Tab5, "S_M", "水量月", 60);
            LoadColumnDate(gvGrid1Tab5, "N1", "初开金额", 100,"0.00");
            LoadColumnDate(gvGrid1Tab5, "N2", "实收金额", 100, "0.00");
            //LoadColumnDate(gvGrid1Tab5, "N3", "欠费调整", 100, "0.00");
            LoadColumnDate(gvGrid1Tab5, "N4", "欠费", 100, "0.00");
            LoadColumnDate(gvGrid1Tab5, "N5", "多收", 100, "0.00");
            LoadColumnDate(gvGrid1Tab5, "M1", "回收率", 100, "0.00");
            LoadColumnDate(gvGrid1Tab5, "M2", "实收/初开", 100, "0.00");
            gvGrid1Tab5.DataSource = this.dtSource5_1;
            gvGrid1Tab5.DataBind();
            this.lsCountYHSF.InnerText = "共" + (this.dtSource5_1.Rows.Count-1).ToString() + "条数据";
            gvGrid1Tab5.FocusedRowIndex = -1;
            gvGrid1Tab5.FocusedRowIndex = 0;

        }
        protected void BtngvGrid2Tab5_Click(object sender, EventArgs e)
        {
            string yonghuh = Convert.ToString(gvGrid1Tab5.GetRowValues(gvGrid1Tab5.FocusedRowIndex, "用户号"));
            if (string.IsNullOrEmpty(yonghuh))
            {
                return;
            }
            DataTable dt = SearchSpHelper.P_QS_CX_YONGHUSFQK(BusinessTool.WType,1,Convert.ToInt32(this.cmbYear.Value),Convert.ToInt32(this.cmbMonth.Value), null, null, yonghuh, null, null, null, null, null, null, null, null, null, null, null, null, null).Tables[0];
            gvGrid2Tab5.Columns.Clear();
            LoadColumnDate(gvGrid2Tab5, "S_M", "水量月", 60);
            LoadColumnDate(gvGrid2Tab5, "N1", "初开金额", 100, "0.00");
            LoadColumnDate(gvGrid2Tab5, "N2", "实收金额", 100, "0.00");
            //LoadColumnDate(gvGrid2Tab5, "N3", "欠费调整", 100, "0.00");
            LoadColumnDate(gvGrid2Tab5, "N4", "欠费", 100, "0.00");
            LoadColumnDate(gvGrid2Tab5, "N5", "多收", 100, "0.00");
            LoadColumnDate(gvGrid2Tab5, "M1", "回收率", 100, "0.00");
            LoadColumnDate(gvGrid2Tab5, "M2", "实收/初开", 100, "0.00");
            gvGrid2Tab5.DataSource = dt;
            gvGrid2Tab5.DataBind();
        }
        #endregion

        #region 全年收费情况查询
        private void BindQNSFCX()
        {
            int year = Convert.ToInt32(cmbYear.Value.ToString());
            int month = Convert.ToInt32(cmbMonth.Value.ToString());

            string huanxian = cmbHuanNeiHW.SelectedIndex <= 0 ? "0" : cmbHuanNeiHW.Value.ToString();
            string xingzhengqu = cmbXingZhengQ.SelectedIndex <= 0 ? "" : cmbXingZhengQ.Value.ToString();

            string yewuy = cmbYeWuY.SelectedIndex <= 0 || cmbYeWuY.Value.ToString() == "-1" ? "" : cmbYeWuY.Value.ToString();
            string yonghuh = txtYongHuH.Text;
            string yonghum = txtYongHuM.Text;
            string dizhi = txtYongHuDZ.Text;
            string yongshuiyt = cmbQuShuiYT.SelectedIndex <= 0 ? "" : cmbQuShuiYT.Value.ToString();
            string hangyelx = cmbHangYeLX.SelectedIndex <= 0 ? "" : cmbHangYeLX.Value.ToString();
            string bumen = cbmGuanLiBM.SelectedIndex <= 0 ? "" : cbmGuanLiBM.Value.ToString();
            string shuijiatj = cmbShuiJia.SelectedIndex <= 0 ? "" : cmbShuiJia.Value.ToString();
            string shuijia = txtShuiJia.Text;
            string liuyu = cmbLiuYu.SelectedIndex <= 0 ? "" : cmbLiuYu.Value.ToString();
            string fenpian = cmbShuiLiFP.SelectedIndex <= 0 ? "" : cmbShuiLiFP.Value.ToString();
            string shuiziyfq = cmbShuiZiYFQ.SelectedIndex <= 0 ? "" : cmbShuiZiYFQ.Value.ToString();
            string shoufeifs = cmbShouFeiFS.SelectedIndex <= 0 ? "" : cmbShouFeiFS.Value.ToString();
            string kaihuhum = txtKaiHuHM.Text;
            string yinhangzh = txtYinHangZH.Text;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (xingzhengqu != "" && xingzhengqu != "0")
            {
                sb.AppendFormat(" and A.S_XINGZHENGQBH='{0}'", xingzhengqu);
            }
            if (huanxian != "0")
            {
                sb.AppendFormat(" and A.S_HUANXIANBJ='{0}'", huanxian);
            }
            if (yewuy != "")
            {
                sb.AppendFormat(" and A.S_YEWUY='{0}'", yewuy);
            }
            if (yonghuh != "")
            {
                sb.AppendFormat(" and A.S_YONGHUH like '%{0}%'", yonghuh);
            }
            if (yonghum != "")
            {
                sb.AppendFormat(" and A.S_YONGHUM like '%{0}%'", yonghum);
            }
            if (dizhi != "")
            {
                sb.AppendFormat(" and A.S_DIZHI like '%{0}%'", dizhi);
            }
            if (yongshuiyt != "")
            {
                sb.AppendFormat(" and A.S_QUSHUIYTBH='{0}'", yongshuiyt);
            }
            if (hangyelx != "")
            {
                sb.AppendFormat(" and A.S_HANGYEBH='{0}'", hangyelx);
            }
            if (bumen != "")
            {
                sb.AppendFormat(" and A.S_BUMENBH='{0}'", bumen);
            }
            double sj = 0;
            if (shuijiatj != "" && shuijia != "" && double.TryParse(shuijia, out sj))
            {
                sb.AppendFormat(" and A.N_SHUIJIA={0}{1}", shuijiatj, shuijia);
            }
            if (liuyu != "")
            {
                sb.AppendFormat(" and A.S_LIUYUBH='{0}'", liuyu);
            }
            if (fenpian != "")
            {
                sb.AppendFormat(" and A.S_FENPIANBH='{0}'", fenpian);
            }
            if (shuiziyfq != "")
            {
                sb.AppendFormat(" and A.S_SHUIZIYBH='{0}'", shuiziyfq);
            }
            if (shoufeifs != "")
            {
                sb.AppendFormat(" and A.I_BIAOSHI='{0}'", shoufeifs);
            }
            if (kaihuhum != "")
            {
                sb.AppendFormat(" and A.S_KAIHUHM='{0}'", kaihuhum);
            }
            if (yinhangzh != "")
            {
                sb.AppendFormat(" and A.S_KAIHUH='{0}'", yinhangzh);
            }
            DataTable dt = _SpHelper.P_QS_CX_QNSFHZCX(BusinessTool.WType, year, month, sb.ToString(), cmbSFHZLX.SelectedIndex).Tables[0];
            gvGridTab6.DataSource = dt;
            gvGridTab6.DataBind();
            zjltab6.Text = "共" + (gvGridTab6.VisibleRowCount - 1) + "条";

        }
        #endregion

        #region 业务员收费情况查询
        private void BindYWYSFCX()
        {
            int year = Convert.ToInt32(cmbYear.Value.ToString());
            int month = Convert.ToInt32(cmbMonth.Value.ToString());

            string huanxian = cmbHuanNeiHW.SelectedIndex <= 0 ? "0" : cmbHuanNeiHW.Value.ToString();
            string xingzhengqu = cmbXingZhengQ.SelectedIndex <= 0 ? "" : cmbXingZhengQ.Value.ToString();

            string yewuy = cmbYeWuY.SelectedIndex <= 0 || cmbYeWuY.Value.ToString() == "-1" ? "" : cmbYeWuY.Value.ToString();
            string yonghuh = txtYongHuH.Text;
            string yonghum = txtYongHuM.Text;
            string dizhi = txtYongHuDZ.Text;
            string yongshuiyt = cmbQuShuiYT.SelectedIndex <= 0 ? "" : cmbQuShuiYT.Value.ToString();
            string hangyelx = cmbHangYeLX.SelectedIndex <= 0 ? "" : cmbHangYeLX.Value.ToString();
            string bumen = cbmGuanLiBM.SelectedIndex <= 0 ? "" : cbmGuanLiBM.Value.ToString();
            string shuijiatj = cmbShuiJia.SelectedIndex <= 0 ? "" : cmbShuiJia.Value.ToString();
            string shuijia = txtShuiJia.Text;
            string liuyu = cmbLiuYu.SelectedIndex <= 0 ? "" : cmbLiuYu.Value.ToString();
            string fenpian = cmbShuiLiFP.SelectedIndex <= 0 ? "" : cmbShuiLiFP.Value.ToString();
            string shuiziyfq = cmbShuiZiYFQ.SelectedIndex <= 0 ? "" : cmbShuiZiYFQ.Value.ToString();
            string shoufeifs = cmbShouFeiFS.SelectedIndex <= 0 ? "" : cmbShouFeiFS.Value.ToString();
            string kaihuhum = txtKaiHuHM.Text;
            string yinhangzh = txtYinHangZH.Text;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (xingzhengqu != "" && xingzhengqu != "0")
            {
                sb.AppendFormat(" and A.S_XINGZHENGQBH='{0}'", xingzhengqu);
            }
            if (huanxian != "0")
            {
                sb.AppendFormat(" and A.S_HUANXIANBJ='{0}'", huanxian);
            }
            if (yewuy != "")
            {
                sb.AppendFormat(" and A.S_YEWUY='{0}'", yewuy);
            }
            if (yonghuh != "")
            {
                sb.AppendFormat(" and A.S_YONGHUH like '%{0}%'", yonghuh);
            }
            if (yonghum != "")
            {
                sb.AppendFormat(" and A.S_YONGHUM like '%{0}%'", yonghum);
            }
            if (dizhi != "")
            {
                sb.AppendFormat(" and A.S_DIZHI like '%{0}%'", dizhi);
            }
            if (yongshuiyt != "")
            {
                sb.AppendFormat(" and A.S_QUSHUIYTBH='{0}'", yongshuiyt);
            }
            if (hangyelx != "")
            {
                sb.AppendFormat(" and A.S_HANGYEBH='{0}'", hangyelx);
            }
            if (bumen != "")
            {
                sb.AppendFormat(" and A.S_BUMENBH='{0}'", bumen);
            }
            double sj = 0;
            if (shuijiatj != "" && shuijia != "" && double.TryParse(shuijia, out sj))
            {
                sb.AppendFormat(" and A.N_SHUIJIA={0}{1}", shuijiatj, shuijia);
            }
            if (liuyu != "")
            {
                sb.AppendFormat(" and A.S_LIUYUBH='{0}'", liuyu);
            }
            if (fenpian != "")
            {
                sb.AppendFormat(" and A.S_FENPIANBH='{0}'", fenpian);
            }
            if (shuiziyfq != "")
            {
                sb.AppendFormat(" and A.S_SHUIZIYBH='{0}'", shuiziyfq);
            }
            if (shoufeifs != "")
            {
                sb.AppendFormat(" and A.I_BIAOSHI='{0}'", shoufeifs);
            }
            if (kaihuhum != "")
            {
                sb.AppendFormat(" and A.S_KAIHUHM='{0}'", kaihuhum);
            }
            if (yinhangzh != "")
            {
                sb.AppendFormat(" and A.S_KAIHUH='{0}'", yinhangzh);
            }
            DataTable dt = _SpHelper.P_QS_CX_QNSFHZCX(BusinessTool.WType, year, month, sb.ToString(), 3).Tables[0];
            gvGridTab7.DataSource = dt;
            gvGridTab7.DataBind();
            zjltab7.Text = "共" + (gvGridTab7.VisibleRowCount - 1) + "条";

        }
        #endregion
        /// <summary>
        /// 给显示框赋值
        /// </summary>
        private void SetData()
        {
            DataTable dt_temp = _SpHelper.P_QSCX_YONGHUXXCX(BusinessTool.WType, 0, 0, "0", "0", -1, null, Convert.ToInt32(gvYongHuXX.GetRowValues(0, "ID"))).Tables[0];
            if (dt_temp != null && dt_temp.Rows.Count > 0)
            {
                txtYongHuH2.Text = dt_temp.Rows[0]["S_YONGHUH"].ToString();
                txtYongHuM2.Text = dt_temp.Rows[0]["S_YONGHUM"].ToString();
                txtHuanNeiHW.Text = dt_temp.Rows[0]["HNHW"].ToString();
                txYouBian.Text = dt_temp.Rows[0]["S_YOUBIAN"].ToString();
                txtDiZhi.Text = dt_temp.Rows[0]["S_DIZHI"].ToString();
                txtXingZhengQ.Text = dt_temp.Rows[0]["S_XINGZHENGQM"].ToString();
                txtLianXiBM.Text = dt_temp.Rows[0]["S_LIANXIBM"].ToString();
                txtLianXiR.Text = dt_temp.Rows[0]["S_LIANXIR"].ToString();
                txtLianXiDH.Text = dt_temp.Rows[0]["S_DIANHUA"].ToString();
                txtLiuYu.Text = dt_temp.Rows[0]["S_LIUYUMC"].ToString();
                txtYeWuY.Text = dt_temp.Rows[0]["S_YEWUY"].ToString();
                txtGuanLiBM.Text = dt_temp.Rows[0]["S_BUMENMC"].ToString();
                txtShuiZiYFQ.Text = dt_temp.Rows[0]["S_SHUIZIYMC"].ToString();
                txtShouFeiFS.Text = dt_temp.Rows[0]["SFFS"].ToString();
                txtShuiJia2.Text = dt_temp.Rows[0]["N_SHUIJIA"].ToString();
                txtQuShuiYT.Text = dt_temp.Rows[0]["S_QUSHUIMC"].ToString();
                txtShuiLiFP.Text = dt_temp.Rows[0]["S_SHUILIFPMC"].ToString();
                txtKaiHuHM2.Text = dt_temp.Rows[0]["S_KAIHUHM"].ToString();
                txtHangYeFL.Text = dt_temp.Rows[0]["S_FENLEIMC"].ToString();
                memoBeiZhu.Text = dt_temp.Rows[0]["S_ZHUSHI"].ToString();
                txtYinHangZH2.Text = dt_temp.Rows[0]["S_KAIHUH"].ToString();
                txtJingShu.Text = dt_temp.Rows[0]["JS"].ToString();
                txtKaiHuYH.Text = dt_temp.Rows[0]["S_KAIHUYH"].ToString();
                txtBiaoShu.Text = dt_temp.Rows[0]["BS"].ToString();
            }
        }

        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            int id = Convert.ToInt32(this.hdCollection.Get("ID"));
            if (e.Parameter == "setinfo")
            {
                string msg = "";
                if (this.dtYongHuXX != null)
                {
                    DataTable dt_temp = _SpHelper.P_QSCX_YONGHUXXCX(BusinessTool.WType, 0, 0, "0", "0", -1, null, id).Tables[0];

                    msg = string.Join("|",
                        dt_temp.Rows[0]["S_YONGHUH"].ToString(),
                        dt_temp.Rows[0]["S_YONGHUM"].ToString(),
                         dt_temp.Rows[0]["HNHW"].ToString(),
                        dt_temp.Rows[0]["S_YOUBIAN"].ToString(),
                        dt_temp.Rows[0]["S_DIZHI"].ToString(),
                        dt_temp.Rows[0]["S_XINGZHENGQM"].ToString(),
                        dt_temp.Rows[0]["S_LIANXIBM"].ToString(),
                        dt_temp.Rows[0]["S_LIANXIR"].ToString(),
                        dt_temp.Rows[0]["S_DIANHUA"].ToString(),
                        dt_temp.Rows[0]["S_LIUYUMC"].ToString(),
                        dt_temp.Rows[0]["S_YEWUY"].ToString(),
                        dt_temp.Rows[0]["S_BUMENMC"].ToString(),
                         dt_temp.Rows[0]["S_SHUIZIYMC"].ToString(),
                         dt_temp.Rows[0]["SFFS"].ToString(),
                        dt_temp.Rows[0]["N_SHUIJIA"].ToString(),
                        dt_temp.Rows[0]["S_QUSHUIMC"].ToString(),
                        dt_temp.Rows[0]["S_SHUILIFPMC"].ToString(),
                        dt_temp.Rows[0]["S_KAIHUHM"].ToString(),
                        dt_temp.Rows[0]["S_FENLEIMC"].ToString(),
                        dt_temp.Rows[0]["S_ZHUSHI"].ToString(),
                        dt_temp.Rows[0]["S_KAIHUH"].ToString(),
                        dt_temp.Rows[0]["JS"].ToString(),
                        dt_temp.Rows[0]["S_KAIHUYH"].ToString(),
                        dt_temp.Rows[0]["BS"].ToString());
                }

                e.Result = e.Parameter + "|0|" + msg;
            }
        }




        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width, string format)
        {
            GridViewDataTextColumn c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            c.PropertiesEdit.DisplayFormatString = format;
            gv.Columns.Add(c);
        }
        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width)
        {
            GridViewDataTextColumn c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            gv.Columns.Add(c);
        }
        #endregion

        protected void gvGrid1Tab2_FocusedRowChanged(object sender, EventArgs e)
        {
            //string yonghuh=Convert.ToString(this.gvGrid1Tab2.GetRowValues(this.gvGrid1Tab2.FocusedRowIndex,"S_YONGHUH"));
            //DataTable dt = null;
            //if (string.IsNullOrEmpty(yonghuh))
            //{
            //    return;
            //}

            //if (BusinessTool.WType == 2)
            //{
            //    dt = SearchSpHelper.P_QS_CX_QUANNIANQKCX_DXS(1, yonghuh, Convert.ToInt32(this.cmbYear.Value), null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).Tables[0];
            //    gvGrid2Tab2.Columns.Clear();
            //        LoadColumnDate(gvGrid2Tab2, "S_M", "月份", 80);
            //        LoadColumnDate(gvGrid2Tab2, "I1", "普通采", 90);
            //        LoadColumnDate(gvGrid2Tab2, "I2", "矿泉采", 90);
            //        LoadColumnDate(gvGrid2Tab2, "I3", "采灌采", 100);
            //        LoadColumnDate(gvGrid2Tab2, "I0", "开采量", 100);
            //        LoadColumnDate(gvGrid2Tab2, "J1", "采灌灌", 100);
            //        LoadColumnDate(gvGrid2Tab2, "J2", "专灌", 100);
            //        LoadColumnDate(gvGrid2Tab2, "J0", "回灌量", 120);
            //        LoadColumnDate(gvGrid2Tab2, "N0", "深井水费", 100);
            //}
            //else
            //{
            //    dt = SearchSpHelper.P_QS_CX_QUANNIANQKCX_DBS(1, yonghuh, Convert.ToInt32(this.cmbYear.Value), null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).Tables[0];
            //    gvGrid2Tab2.Columns.Clear();
            //    LoadColumnDate(gvGrid2Tab2, "S_M", "月份", 80);
            //    LoadColumnDate(gvGrid2Tab2, "I1", "取水量", 90);
            //    LoadColumnDate(gvGrid2Tab2, "I2", "开账水量", 100);
            //    LoadColumnDate(gvGrid2Tab2, "I3", "发电量", 100);
            //    LoadColumnDate(gvGrid2Tab2, "I4", "开账电量", 100);
            //    LoadColumnDate(gvGrid2Tab2, "N0", "金额", 100);
            //}
            //gvGrid2Tab2.DataSource = dt;
            //gvGrid2Tab2.DataBind();
        }

        protected void gvGrid2Tab5_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            string yonghuh = e.Parameters;
            if (string.IsNullOrEmpty(yonghuh))
            {
                return;
            }
            DataTable dt = SearchSpHelper.P_QS_CX_YONGHUSFQK(BusinessTool.WType, 1, Convert.ToInt32(this.cmbYear.Value), Convert.ToInt32(this.cmbMonth.Value), null, null, yonghuh, null, null, null, null, null, null, null, null, null, null, null, null, null).Tables[0];
            gvGrid2Tab5.Columns.Clear();
            LoadColumnDate(gvGrid2Tab5, "S_M", "水量月", 100);
            LoadColumnDate(gvGrid2Tab5, "N1", "初开金额", 100);
            LoadColumnDate(gvGrid2Tab5, "N2", "实收金额", 100);
            //LoadColumnDate(gvGrid2Tab5, "N3", "欠费调整", 100);
            LoadColumnDate(gvGrid2Tab5, "N4", "欠费", 100);
            LoadColumnDate(gvGrid2Tab5, "N5", "多收", 100);
            LoadColumnDate(gvGrid2Tab5, "M1", "回收率", 100);
            LoadColumnDate(gvGrid2Tab5, "M2", "实收/多开", 100);
            gvGrid2Tab5.DataSource = dt;
            gvGrid2Tab5.DataBind();
        }

        protected void gvGrid2Tab2_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            string yonghuh = e.Parameters;
            loadQuanNian2(yonghuh);
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            int index = ASPxPageControl1.ActiveTabIndex;
            string sName = "";
            if (index == 0)
            {
                gvYongHuXX.DataSource = this.dtYongHuXX;
                this.gvYongHuXX.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvYongHuXX";
                sName = "用户信息";
                gvYongHuXX.Settings.ShowFooter = false;
                for (int i = 0; i < this.dtYongHuXX.Rows.Count; i++)
                {
                    DataRow row = this.dtYongHuXX.Rows[i];
                    for (int j = 0; j < this.dtYongHuXX.Columns.Count; j++)
                    {
                        if (row[j].GetType().Equals(typeof(string)) && Regex.IsMatch(row[j].ToString(), @"^[+-]?\d*$"))
                        {
                            row[j] = "\r" + row[j];
                        }
                    }
                }
            }
            else if (index == 1)
            {
                gvGrid1Tab2.DataSource = dtGridTab2_1;
                gvGrid1Tab2.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvGrid1Tab2";
                sName = "全年用水情况";
                gvGrid1Tab2.Settings.ShowFooter = false;
            }
            else if (index == 2)
            {
                gvGridTab3.DataSource = dtGridTab3;
                gvGridTab3.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvGridTab3";
                sName = "月用水情况";
                gvGridTab3.Settings.ShowFooter = false;
            }
            else if (index == 3)
            {
                gvGridTab4.DataSource = dtGridTab4;
                gvGridTab4.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvGridTab4";
                sName = "月用水汇总";
                gvGridTab4.Settings.ShowFooter = false;
            }
            else if (index == 4)
            {
                ASPxGridViewExporter1.GridViewID = "gvGrid1Tab5";
                sName = "用户收费情况";
                gvGrid1Tab5.Settings.ShowFooter = false;
            }
            else if (index == 5)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridTab6";
                sName = "全年收费情况";
                gvGridTab6.Settings.ShowFooter = false;
            }
            else if (index == 6)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridTab7";
                sName = "业务员收费情况";
                gvGridTab7.Settings.ShowFooter = false;
            }


            ASPxGridViewExporter1.WriteXlsToResponse(sName);

        }

        protected void btnExport2_2_Click(object sender, EventArgs e)
        {
            string yonghuh = Convert.ToString(this.gvGrid1Tab2.GetRowValues(this.gvGrid1Tab2.FocusedRowIndex, "S_YONGHUH"));
            loadQuanNian2(yonghuh);
            //gvGrid2Tab2.DataSource = dtGridTab2_2;
            //gvGrid2Tab2.DataBind();
            ASPxGridViewExporter1.GridViewID = "gvGrid2Tab2";
            string sName = "用户用水信息";
            gvGrid2Tab2.Settings.ShowFooter = false;
            ASPxGridViewExporter1.WriteXlsToResponse(sName);
        }



    }
}